<%--
  Created by IntelliJ IDEA.
  User: sunhao
  Date: 2016/5/4
  Time: 14:17
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE HTML>
<html>
<head>
    <title>学生课程信息</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <%--<link href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">--%>
    <link href="/static/bui/css/bs3/dpl.css" rel="stylesheet" type="text/css"/>
    <link href="/static/bui/css/bs3/bui.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="doc-content">
    <div class="panel">
        <div class="panel-header">
            <h3>${studentName}学生课程信息</h3>
        </div>
        <div class="panel-body">
            <c:forEach items="${lessons}" var="p">
                <div class="row detail-row">
                    <div class="span8">
                        <label>所学课程：</label><span class="detail-text">${p.name}</span>
                    </div>
                    <div class="span8">
                        <label>剩余数量：</label><span class="detail-text">${p.n}节</span>
                    </div>
                    <div class="span8">
                        <label>调整为：</label><input name="${p.id}" type="text"/>节
                        <button class="button button-primary" style="margin-left: 20px">提交</button>
                    </div>
                </div>
            </c:forEach>
        </div>
    </div>
</div>
<script type="text/javascript" src="/static/bui/js/jquery-1.8.1.min.js"></script>
<script type="text/javascript" src="/static/bui/js/bui.js"></script>
<script type="text/javascript" src="/static/bui/js/config.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $('.button-primary').click(function () {
            var lessonId = $(this).prev().attr('name'), n = $(this).prev().val()
            $.ajax({
                type: 'post',
                url: '/student/updateLesson?studentId=' + '${studentId}' + '&lessonId=' + lessonId + '&n=' + n,
                success: function (msg) {
                    if (msg == 'success') {
                        msg = "修改成功！";
                        BUI.Message.Alert(msg, function () {
                            location.reload(true)
                        }, 'success')
                    } else {
                        msg = "修改失败,你没有权限";
                        BUI.Message.Alert(msg, function () {
                            window.location.href = '/jsp/error/noAuthority.jsp';
                        }, 'error')
                    }

                }
            })
        })
    })
</script>
</body>
</html>
